import {lazy} from 'react';
import {RouteConfig} from 'react-router-config';

const UploadItem = lazy(() => import('@/pages/Upload'));

const GeoTable = lazy(() => import('@/components/GeoTable'));

const EditForm = lazy(() => import('@/pages/FormList'));
const Echart = lazy(() => import('@/pages/Echart'));
const TableDrag = lazy(() => import('@/pages/TableDrag'));
const Panel = lazy(() => import('@/pages/Panel'));
const App = lazy(() => import('@/components/Layout'));
const KeepComponent = lazy(() => import('@/components/KeepAlive'));
const AutoPlay = lazy(() => import('@/components/AutoPlay'));
const FlowItem = lazy(() => import('@/components/Flow'));

/* 
    export interface RouteConfig {
        path?: string;
        exact?: Boolean;
        component?: any;
        routes?: RouteConfig[];
    }
*/

// 第二种 使用对象

export const routes: RouteConfig[] = [
    {
        component: App,
        routes: [
            {
                path: '/panel',
                exact: true,
                component: Panel,
            },
            {
                path: '/tableDrag',
                exact: true,
                component: TableDrag,
            },
            {
                path: '/geoTable',
                exact: true,
                component: GeoTable,
            },
            {
                path: '/echart',
                exact: true,
                component: Echart,
            },
            {
                path: '/editForm',
                component: EditForm,
                routes: [
                    {
                        path: '/editForm/search',
                        exact: true,
                        component: EditForm,
                    },
                ],
            },
            {
                path: '/flow',
                exact: true,
                component: FlowItem,
            },
            {
                path: '/upload',
                exact: true,
                component: EditForm,
            },
            {
                path: '/keepalive',
                exact: true,
                component: KeepComponent,
            },
            {
                path: '/autoPlay',
                exact: true,
                component: AutoPlay,
            },
        ],
    },
];
